package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 口味数据层
 */
@Mapper
public interface DishFlavorMapper {

    /**
     * 批量添加口味内容到数据库
     * @param flavors
     */
    void insertDishFlavorBatch(List<DishFlavor> flavors);

    /**
     * 通过 dishId 获取当前菜品的所有口味
     * @param dishId
     * @return
     */
    @Select("select * from dish_flavor where dish_id = #{dishId}")
    List<DishFlavor> selectDishFlavorByDishId(Long dishId);

    /**
     * 通过 dishId 更新口味
     * @param dishFlavors
     */
    void updateDishFlavorBatch(List<DishFlavor> dishFlavors);

    /**
     * 删除此产品中原先用户没有选择的口味
     * @param dishFlavors
     */
    void deleteDishFlavorBatch(List<DishFlavor> dishFlavors);

    /**
     * 通过 dishId 删除 菜品口味
     * @param id
     */
    @Delete("delete from dish_flavor where dish_id = #{id}")
    void deleteDishFlavorByDishId(Long id);
}
